<?php
   
class API_Settings extends API_Class {
                    
    public static $table = 'settings';
                    
    public function getParam($key, $info = false){
        //return "";
		//$ret = self::$db->fetchRow(self::$db->select()->from(self::$table)->where('key = ?',$key));
        $ret = self::$db->fetchRow("SELECT * FROM settings WHERE (key = '".$key."')");
        if(!$ret)
            throw new Exception('Отсутствует настройка "'.$key.'"');
        return $info ? $ret : $ret['value'];
    }        
    
    public function newParam($key, $value, $text){
        self::$db->query("insert into settings (key, value, text) values ('".$key."', '".$value."', '".$text."')");
    }

}